image=imread("fig6.tif");
temp=im2double(image);
[h,w]=size(temp);
result=im2double(zeros(h,w));
subplot(2,2,1),imshow(temp);
subplot(2,2,2),imhist(temp);
a=0.3;
a1=0.2;
b=0.6;
b1=0.6;
m1=1;
for i=1:h
    for j=1:w
        if temp(i,j)<a
            result(i,j)=a1/a*temp(i,j);
        elseif temp(i,j)<b
            result(i,j)=a1+(b1-a1)/(b-a)*(temp(i,j)-a);
        else
            result(i,j)=b1+(1-b1)/(1-b)*(temp(i,j)-b);
        end
    end
end
subplot(2,2,3),imshow(result);
subplot(2,2,4),imhist(result);



